package priv.pattern.prototypepattern;

import org.junit.Test;
import priv.pattern.prototypepattern.abs.impl.Circle;
import priv.pattern.prototypepattern.abs.impl.Rectangle;
import priv.pattern.prototypepattern.abs.impl.Square;

/*
 * 作者：m鹏h
 * 时间；2024/7/4 21:44
 * 描述：原型模式 客户端
 **/
public class PrototypePatternTest {

    @Test
    public void  test(){
        //进行初始化对象
        ShapeCache.loadCache();


        //反射的向下转型
        Circle circle = (Circle) ShapeCache.getShape("1");
        circle.draw();
        System.out.println("圆形 id:"+circle.getId());

        Square square = (Square) ShapeCache.getShape("2");
        square.draw();
        System.out.println("正方形 id:"+square.getId());

        Rectangle readable = (Rectangle) ShapeCache.getShape("3");
        readable.draw();
        System.out.println("长方形 id:"+readable.getId());



    }
}
